﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GISEntity;

namespace SLServiceLibrary
{
    public class SignleAreaValue
    {
        private Server dbServer = new Server();
        public decimal GetSignleAreaValue(DateTime Time, string cityName, string industryTypeName,string countyName)
        {
            decimal value = 0;//最终返回值
            int industrytypename = 0;
            IndusryType it = new IndusryType();
            industrytypename = it.GetIndustryName(industryTypeName);
            using (HnMapEntities database = new HnMapEntities(dbServer.GetConnectString()))
            {
                switch (industrytypename)
                {
                    case 1:
                        #region
                        {
                            var queryResult = from s in database.AGRICULTURALs
                                              where (s.CITYNAME.Equals(cityName) && s.TIME.Equals(Time))
                                              select s;
                            var temp = queryResult.Single() as AGRICULTURAL;

                            value = temp.FARMINGVALUE + temp.FORESTYVALUE
                                     + temp.HUSBANDRYVALUE + temp.FISHERYVALUE + temp.SERVICEVALUE;
                            //value =(double) temp.AGRVALUE + (double)temp.INDUSTRYVALUE + (double)temp.BUILDINGVALUE
                            //         + (double)temp.TRANSPORTVALUE + (double)temp.RETAILVALUE + (double)temp.RETAILVALUE;
                        }
                        #endregion
                        break;
                    case 2:
                        #region
                        {
                            var queryResult = from s in database.COUNTYINDUSTRies
                                              where (s.COUNTYNAME.Equals(countyName) && s.TIME.Equals(Time))
                                              select s;
                            var temp = queryResult.Single() as COUNTYINDUSTRY;
                            value=temp.INDUSTRYVALUE + temp.BUILDINGVALUE + temp.TRANSPORTVALUE
                                + temp.RETAILVALUE + temp.ESTATEVALUE + temp.SERVICEVALUE + temp.TOURISMVALUE;

                            //////////////////////
                            //////////////////////
                            /////////////////////
                            Console.WriteLine(value);
                            
            //////////////////////
            //////////////////////
            /////////////////////

                        }
                        #endregion
                        break;
                    case 3:
                        #region
                        {
                            var queryResult = from s in database.INDUSTRies
                                              where (s.CITYNAME.Equals(cityName) && s.TIME.Equals(Time))
                                              select s;
                            var temp = queryResult.Single() as INDUSTRY;
                            value = temp.FIANCEVALUE + temp.INDUSTRYVALUE + temp.BUILDINGVALUE + temp.TRANSPORTVALUE
                            + temp.RETAILVALUE + temp.ESTATEVALUE + temp.SERVICEVALUE + temp.TOURISMVALUE;

                        }
                        #endregion
                        break;
                }
            }
            //////////////////////
            //////////////////////
            /////////////////////
            Console.WriteLine(value);

            //////////////////////
            //////////////////////
            /////////////////////
            return value;
   
        }
    }
}